home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / tclX6.4c / dist / tests / math.test < prev    next >
Encoding:
Text File  |  1992-11-07  |  2.2 KB  |  90 lines

  1. #
  2. # math.test
  3. #
  4. # Tests for the random, min, and commands.
  5. #---------------------------------------------------------------------------
  6. # Copyright 1992 Karl Lehenbauer and Mark Diekhans.
  7. #
  8. # Permission to use, copy, modify, and distribute this software and its
  9. # documentation for any purpose and without fee is hereby granted, provided
  10. # that the above copyright notice appear in all copies.  Karl Lehenbauer and
  11. # Mark Diekhans make no representations about the suitability of this
  12. # software for any purpose.  It is provided "as is" without express or
  13. # implied warranty.
  14. #------------------------------------------------------------------------------
  15. # $Id: math.test,v 2.0 1992/10/16 04:50:02 markd Rel $
  16. #------------------------------------------------------------------------------
  17. #
  18.  
  19. if {[info procs test] != "test"} then {source testlib.tcl}
  20.  
  21. random seed 100
  22.  
  23. for {set i 0} {$i < 100} {set i [expr $i+1]} {
  24.     Test math-1.1.$i {random tests} {
  25.         set a [random 10]
  26.         expr "(($a >= 0) || ($a <= 9))"
  27.     } 0 1
  28. }
  29.  
  30. Test math-1.2 {random tests} {
  31.     random
  32. } 1 {wrong # args: random limit | seed [seedval]}
  33.  
  34. Test math-1.3 {random tests} {
  35.     # Max range varies on some machines, so don't validate that part of
  36.     # the message.
  37.     list [catch {random 0} msg] [lrange $msg 0 6]
  38. } 0 {1 {range must be > 0 and <=}}
  39.  
  40. Test math-1.4 {random tests} {
  41.     random seed Foo
  42. } 1 {expected integer but got "Foo"}
  43.  
  44. Test math-2.1 {max tests} {
  45.     max 1 2 4 3
  46. } 0 4
  47.  
  48. Test math-2.2 {max tests} {
  49.     max -68 65537.4 2 5
  50. } 0 65537.4
  51.  
  52. Test math-2.3 {max tests} {
  53.     max -68.7 2100000000 2 5
  54. } 0 2100000000
  55.  
  56. Test math-2.4 {max tests} {
  57.     max -68.7 -2
  58. } 0 -2
  59.  
  60. Test math-2.5 {max tests} {
  61.     max
  62. } 1 {wrong # args: max num1 num2 [..numN]}
  63.  
  64. Test math-2.6 {max tests} {
  65.     max 1 2 3 foo
  66. } 1 {expected floating-point number but got "foo"}
  67.  
  68. Test math-3.1 {min tests} {
  69.     min 1 2 4 3
  70. } 0 1
  71.  
  72. Test math-3.2 {min tests} {
  73.     min -68.8 64000 2 5
  74. } 0 -68.8
  75.  
  76. Test math-3.3 {min tests} {
  77.     min -2000000000 2000000000 2 5
  78. } 0 -2000000000
  79.  
  80. Test math-3.4 {min tests} {
  81.     min
  82. } 1 {wrong # args: min num1 num2 [..numN]}
  83.  
  84. Test math-3.5 {min tests} {
  85.     min 1 2 3 foo
  86. } 1 {expected floating-point number but got "foo"}
  87.  
  88.  
  89.  
  90.